package response

import (
	"github.com/gin-gonic/gin"
	"net/http"
)

//数据返回格式
//优化了之前的ctx.JSON
func Response(ctx *gin.Context,httpStatus int,code int,data gin.H,msg string){
	ctx.JSON(httpStatus,gin.H{
		"code":code,
		"data":data,
		"msg":msg,
	})
}

func Success(ctx *gin.Context,data gin.H,msg string){
	Response(ctx,http.StatusOK,200,data,msg)
}

func Fail(ctx *gin.Context,data gin.H,msg string){
	Response(ctx,http.StatusOK,400,data,msg)
}
